__author__ = 'nvsmirnov'
# -*- coding: utf-8 -*-

import unittest
from Framework.DataClasses.CUser import *
from Framework.PageClasses.CpLogin import CpLogin
from Framework.PageClasses.CpDefault import CpDefault
from Framework.PageClasses.CpFirstPartAuction import CpFirstPartRequest
from Framework.DataClasses.DatabaseData import createDatabaseData
from Tests._tcBase import _tcBase

class FirstPartAuction(unittest.TestCase, _tcBase):
    """
    Класс тестирует расмотрение первых частей аукциона
    """
    auction = createDatabaseData()
    auction_id = auction.insertAuction5()
    print "Получили id добавленного аукциона: ", auction_id

    def setUp(self):
        _tcBase.setUpFireFox(self)

    def tearDown(self):
        _tcBase.tearDown(self)
        #_tcBase.clear_ie_cache(self)

    def test_1_FirstPartAuction(self, id=auction_id):
        #Заходим в систему под пользователем с ролью Заказчик
        pageLogin = CpLogin(self.driver)
        pageLogin.open(self.driver, pageLogin.url)
        pageLogin.loginAs(user1)

        pageFirstPageAuction = CpFirstPartRequest(self.driver)
        pageFirstPageAuction.openMainPage()
        pageFirstPageAuction.viewAuction(id)
        pageFirstPageAuction.fillRequest()
        pageFirstPageAuction.submitForm()

        pageDefault = CpDefault(self.driver)
        pageDefault.LogOut()

    def test_2_delete_auction(self, id=auction_id):
        delete_auction = createDatabaseData()
        delete_auction.delete_auction(delete_id=id)

if __name__ == '__main__':
    unittest.main()
